<%@page import="java.util.Date" %>
<%!
/*
*====================================================================
*					www.YiiPay.com
*
*                易支付 提供技术支持
*
*     		本页面为功能函数，请不要修改此文件的内容
*
*====================================================================
*/
	/** 绑定多个支付宝账号时，随机获取一个支付宝账号 */
	String GetRndAliAccount(String aliAccount, int jiaoHuanTime) {
		String result = "";
		String _aliAccount = FilterAccount(aliAccount);
		//构建数组
		String[] arr = _aliAccount.split(";");
		int len = arr.length;
		if( len > 0) {
			int idx;
			if(jiaoHuanTime > 0 ) {				
				idx = (int)(((new Date().getTime()/60)/jiaoHuanTime) % len);
			}else {
				idx = (int) (Math.floor( len * Math.random() ));				
			}
			result = arr[idx];
		}else {
			result=_aliAccount;
		}
		
		return result;
	}

	/** 过滤绑定的支付宝账号格式 */
	String FilterAccount(String aliAccount) {
		// 过滤空格，逗号，中文分号
		String _aliAccount = aliAccount;
		_aliAccount = _aliAccount.replace(" ", "").replace("，", ",").replace(",",";").replace("；", ";");
		
		// 过滤数组防止空元素
		String[] arr = _aliAccount.split(";");
		int len = arr.length;
		String str = "";
		String ands = "";
		for (int i = 0; i < len; i++) {
			if (arr[i] != "") {
				str += ands + arr[i];
				ands = ";";
			}
		}
		return str;
	}
%>